<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta charset="utf-8" />
		<title>孕周验证</title>
		<meta name="keywords" content="母婴监护系统" />
		<meta name="description" content="母婴监护系统" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	
	<link rel="stylesheet" type="text/css" href="./jquery-easyui-1.3.5/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="./jquery-easyui-1.3.5/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="./jquery-easyui-1.3.5/demo.css">
	<script type="text/javascript" src="./jquery-easyui-1.3.5/jquery.min.js"></script>
	<script type="text/javascript" src="./jquery-easyui-1.3.5/jquery.easyui.min.js"></script>
<script type="text/javascript">
	
window.onload = function()
{	
  $('#cc').calendar({
  onSelect: function(date){
  var year = date.getFullYear();
  var month = (date.getMonth()+1);
  var day = date.getDate();
  document.getElementById("time").innerHTML="您的怀孕日期是："+year+"/"+month+"/"+day;
  
  var pregweeks=getPregWeeks(year,month-1,day);

  
  if(pregweeks!=undefined)
  {
      document.getElementById("weekid").value=pregweeks;
  }
  else
  {
	  document.getElementById("weekid").value="";
  }
  
  }
  }); 
} 


function getPregWeeks(pregyear,pregmonth,pregday){

   var DateS = new Date(pregyear,pregmonth,pregday);
   var DateE = new Date();
   DateE.getFullYear();    //获取完整的年份(4位,1970-????)
   DateE.getMonth();       //获取当前月份(0-11,0代表1月)
   DateE.getDate();        //获取当前日(1-31)
   DateE.setHours(00);
   DateE.setMinutes(00);
   DateE.setSeconds(00);
   DateE.setMilliseconds(000);
   if(DateS>DateE)
   {
    document.getElementById("week").innerHTML="请选择正确的日期！"
   }
   else
   {
   iDays = parseInt(Math.abs(DateS - DateE) / 1000 / 60 / 60 /24)+1;//把相差的毫秒数转换为天数 
   var iWeeks = parseInt(iDays/7);                                           //把相差的天数转换为周数 
   document.getElementById("week").innerHTML="您的孕周数为："+iWeeks;
   }

   return iWeeks ;
}



</script>
</head>

	<body>
	
			恭喜您，${temploginbean.userName}！<br/>


			
			
	
		<div class="demo-info" style="margin-bottom:10px">
		<div class="demo-tip icon-tip"></div>
		<div>请选择您末次月经的第一天的日期</div>
	</div>
	
	<div class="easyui-calendar" id="cc" style="width:180px;height:180px;"></div>
	<div id="time">末次月经的第一天：</div>
	<div id="expect">您的预产期为：</div>
	<div id="week">您的孕周为:</div>
	
			输入孕周数：<s:form action="Week_getWeekKnowledge2Action" method="post">
			<s:textfield id="weekid" name="weekid"></s:textfield>
			<s:submit value="确定"></s:submit>
			</s:form>

</body>
</html>